package com.banksoft.cps.controller.admin;

import com.banksoft.cps.bean.CompanyUser;
import com.banksoft.cps.bean.SupplierOutWarehouse;
import com.banksoft.cps.bean.query.SupplierOutWarehouseQuery;
import com.banksoft.cps.bean.warpper.SupplierOutWarehouseWarpper;
import com.banksoft.cps.controller.ControllerConstants;
import com.banksoft.cps.service.SupplierOutWarehouseService;
import com.banksoft.cps.util.PageUtils;
import com.banksoft.cps.util.UserContext;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by rongzhao.zhu on 2018/1/12.
 */
@Controller
@RequestMapping("/admin/supplierOutWarehouse/")
public class AdminSupplierOutWarehouseController extends ControllerConstants {
    @Autowired
    SupplierOutWarehouseService supplierOutWarehouseService;


    @RequestMapping(value = "list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String list(SupplierOutWarehouseQuery query){

        List<SupplierOutWarehouseWarpper> list =  supplierOutWarehouseService.list(query);
        return toJSONString(createDataTip(list));
    }
    @RequestMapping(value = "count", produces = "application/json;charset=utf-8")
    @ResponseBody
    public String count(SupplierOutWarehouseQuery query){

        long count =  supplierOutWarehouseService.count(query);
        long pageCount = PageUtils.getPage(count,query.getSize());
        return toJSONString(createDataTip(pageCount));
    }

    @RequestMapping(value = "find",produces = "application/json;charset=utf-8")
    @ResponseBody
    public String find(String id){
        SupplierOutWarehouse supplierOutWarehouse = supplierOutWarehouseService.findById(id);
        return toJSONString(createDataTip(supplierOutWarehouse));
    }


}
